package com.bdsy.business.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bdsy.business.dao.OrderDetailsMapper;
import com.bdsy.business.model.OrderDetails;
import com.bdsy.business.service.OrderDetailsService;

@Service("orderDetailsService")
public class OrderDetailsServiceImpl implements OrderDetailsService {

	@Autowired
	OrderDetailsMapper orderDetailsMapper;
	@Override
	public boolean add(OrderDetails orderDetails) {
		orderDetails.setId((int)((Math.random()*9+1)*10000000));
		orderDetails.setStatus(0);
		int result = orderDetailsMapper.insert(orderDetails);
		return result>0?true:false;
	}
	
	@Override
	public boolean insertOrderDetails(List<OrderDetails> listOrderDetails) {
		for (OrderDetails order : listOrderDetails) {
			order.setId((int)((Math.random()*9+1)*10000000));
			order.setStatus(0);
		}
		int result = orderDetailsMapper.insertOrderDetails(listOrderDetails);
		return result>0?true:false;
	}

	@Override
	public boolean deleteOrderDetailsById(List<String> pIds) {
		int result = orderDetailsMapper.deleteOrderDetailsById(pIds);
		return result>0?true:false;
	}

	@Override
	public boolean updateOrderDetailsStatus(OrderDetails orderDetails) {
		int result = orderDetailsMapper.updateOrderDetailsStatus(orderDetails);
		return result>0?true:false;
	}

	@Override
	public boolean updateOrderDetailStatus(OrderDetails orderDetails) {
		int result = orderDetailsMapper.updateOrderDetailStatus(orderDetails);
		return result>0?true:false;
	}

}
